#pragma once

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>

#define SIZE 4096       //缓冲区大小
#define NONE_FLUSH (1<<1)   //无缓冲
#define LINE_FLUSH (1<<2)   //行缓冲
#define FULL_FLUSH (1<<3)   //全缓冲


typedef struct _myFILE
{
    char outbuffer[SIZE];       //缓冲区
    int pos;                    //缓冲区标志位
    int cap;                    //缓冲区大小        
    int fileno;                 //文件描述符
    int flush_mode;             //选项
}myFILE;

myFILE *my_fopen(const char *pathname, const char *mode);

int my_fwrite(myFILE *fp, const char *s, int size);

//int my_fread();

void my_fflush(myFILE *fp);

void my_fclose(myFILE *fp);

void DebugPrint(myFILE *fp);